﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ITunesSolver.Helpers;
using ITunesSolver.Helpers.DataVirtualization;

namespace ITunesSolver.UI
{
    /// <summary>
    /// Interaction logic for PlayListGrid.xaml
    /// </summary>
    public partial class PlayListGrid : UserControl
    {
        private PlaylistProvider playlistProvider;
        public static HashSet<Playlist> Playlists { get; set; }

        public PlayListGrid()
        {
            InitializeComponent();
        }

        public void Initialize(HashSet<Playlist> playlists)
        {
            lvPlaylists.SelectedIndex = 0;
            lvPlaylists.ItemsSource = null;

            if (playlists == null) return;

            Playlists = playlists;

            playlistProvider = new PlaylistProvider(Playlists);
            AsyncVirtualizingCollection<Playlist> vPlaylists = new AsyncVirtualizingCollection<Playlist>(playlistProvider, 30 /*page size*/, 30000 /*timeout*/);
            //lvPlaylists.DataContext = vPlaylists;
            lvPlaylists.ItemsSource = vPlaylists;
        }

    }
}
